#pragma once

#include <QtGui/QMainWindow>
#include "ui_galcon.h"
#include "game.h"
#include "mainmenu.h"
#include "HostnameSelectDlg.h"
#include "AbstractMessageFactory.h"
#include <boost/enable_shared_from_this.hpp>

class galcon : public QMainWindow, public boost::enable_shared_from_this<galcon>
{
   Q_OBJECT

public:
   galcon(QWidget *parent = 0, Qt::WFlags flags = 0);
   ~galcon();
signals:
   void newMessageRecieved(const Message& messagePtr);
protected:
   void keyPressEvent(QKeyEvent *event);
private slots:
   void handleMessage(const Message&  messagePtr);
   void startLocalGame();
   void startLANGame();
   void connectToHost();
   void onSendNewMessageHandler(const Message& newMessage);
private:
   void disconnectSignals();
   void init();
   void initMainMenu();
   void scaleView(qreal scaleFactor);


   // handlers for GalconClient
   void onConnectFailedHandler(const Message& newMessage);
   void onNewMessageHandler(const Message& newMessage);
   
   boost::shared_ptr<QGraphicsView> m_mainGraphicsView;
   HostnameSelectDlg m_hostnameSelectDlg;
   boost::shared_ptr<MainMenu> m_mainMenu;
   AbstractMessageFactoryPtr m_messageFactory;
   // used when user is played in network game
   GalconClientPtr m_client;
   boost::shared_ptr<Game> m_game;
   Ui::galconClass ui;
};

typedef boost::shared_ptr<galcon> GalconPtr;